package org.wmq.shopmanager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.wmq.shopmanager.mapper.SystemRoleMapper;
import org.wmq.shopmanager.service.SystemRoleService;
import org.wmq.shopmodel.DTO.system.SystemRoleDTO;
import org.wmq.shopmodel.Entity.system.SystemRole;

@Service
@RequiredArgsConstructor
public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemRole> implements SystemRoleService {
    private final SystemRoleMapper systemRoleMapper;

    @Override
    public IPage<SystemRole> getPageItem(SystemRoleDTO systemRoleDTO) {
        LambdaQueryWrapper<SystemRole> queryWrapper = new LambdaQueryWrapper<>();
        String roleName = systemRoleDTO.getRoleName();
        if (roleName != null && !roleName.trim().equals("")){
            queryWrapper.like(SystemRole::getName,roleName);
        }
        Page<SystemRole> page = new Page<>(systemRoleDTO.getPageNo(),systemRoleDTO.getPageSize());
        return this.page(page,queryWrapper);
    }
}
